package top.raoqq.sky.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import top.raoqq.sky.enums.SkyResponseEnum;

/**
 * @author 饶奇奇
 * @date 2023/8/3
 * 通用返回类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public static Result<Void> success() {
        return new Result<>(SkyResponseEnum.SUCCESS.getCode(), SkyResponseEnum.SUCCESS.getMessage(), null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(SkyResponseEnum.SUCCESS.getCode(), SkyResponseEnum.SUCCESS.getMessage(), data);
    }

    public static <T> Result<T> fair(T data) {
        return new Result<T>(SkyResponseEnum.FAIR.getCode(), SkyResponseEnum.FAIR.getMessage(), data);
    }

    public static  Result<Void> fair() {
        return new Result<>(SkyResponseEnum.FAIR.getCode(), SkyResponseEnum.FAIR.getMessage(), null);
    }
    public static  Result<Void> fair(String message) {
        return new Result<>(SkyResponseEnum.FAIR.getCode(), message, null);
    }

    public static  Result<Void> ajax(SkyResponseEnum skyResponseEnum) {
        return new Result<>(skyResponseEnum.getCode(), skyResponseEnum.getMessage(), null);
    }

    public static<T>  Result<T> ajax(SkyResponseEnum skyResponseEnum, T data) {
        return new Result<T>(skyResponseEnum.getCode(), skyResponseEnum.getMessage(), data);
    }


}
